<template>
    <div style="margin-top: -10px;">
        <a-space>
            <a-button type="primary" @click="success" style="height:40px">
                <template #icon>
                    <save-outlined />
                </template>
                保存</a-button>
        </a-space>
        <!-- <a-button type="primary" :size="size" @click="sheetSave">
        <template #icon>
            <save-outlined />
        </template>
        保存
    </a-button> -->

        <a-button type="primary" :size="size" style="margin-left: 30px;">
            <template #icon>
                <red-envelope-outlined />
            </template>
            收费
        </a-button>
    </div>
</template>

<script lang="ts">
import { message } from 'ant-design-vue';
import { defineComponent, ref, onMounted, watchEffect } from 'vue'
import { SaveOutlined, RedEnvelopeOutlined } from '@ant-design/icons-vue';
import type { SizeType } from 'ant-design-vue/es/config-provider'
// import Bus from "../../../utils/Bus"
import Bus from "@/mitt/index"
import { useStore } from "vuex"
export default defineComponent({
    components: { SaveOutlined, RedEnvelopeOutlined },
    setup() {

        const store = useStore()
        let flag = ref(false)
        watchEffect(() => {
            flag.value = store.state.addSuccess
            if (flag.value) {
                message.success('保存成功');
            }
            console.log("store", store.state.addSuccess)
        })
        const sheetSave = () => {
        }

        const success = () => {

            Bus.emit("saveSuccess")
        };
        // onMounted(() => {
        // watchEffect(() => {
        //     Bus.on("test", (res: any) => {
        //         if (res == 8) {
        //             flag.value = true
        //         } else {
        //             flag.value = false
        //         }
        //     })


        // })
        // })
        watchEffect(() => {
            console.log(flag.value)
        })
        const error = () => {
            message.error('This is an error message');
        };
        const warning = () => {
            message.warning('This is a warning message');
        };
        return {
            success,
            error,
            warning,
            size: ref<SizeType>('large'),
            sheetSave
        };
    }
})
</script>

<style scoped lang="less">
.ant-btn:nth-child(1) {
    background-color: #666ee8;
    border: 0px;
    font-size: 16px;
    width: 120px;
    margin-left: 1000px;
}

.ant-btn:nth-child(2) {
    background-color: #ffc71c;
    border: 0px;
    font-size: 16px;
    width: 120px
}
</style>